package com.jgj.zxkj.lookandcheckjggroupinfo.record.person;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;

import com.jgj.zxkj.lookandcheckjggroupinfo.R;
import com.jgj.zxkj.lookandcheckjggroupinfo.record.person.list.ListAdapter;
import com.jgj.zxkj.lookandcheckjggroupinfo.record.person.list.ListBean;
import com.jgj.zxkj.lookandcheckjggroupinfo.record.person.list.ListItemType;
import com.jgj.zxkj.lookandcheckjggroupinfo.resetpwd.ResetPwdDelegate;
import com.sa.all_cui.mix_core.delegate.bottom.BottomItemDelegate;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by all-cui on 2017/10/27.
 */

public class PersonDelegate extends BottomItemDelegate {
    @BindView(R.id.common_toolbar)
    Toolbar mToolbar = null;
    @BindView(R.id.tv_toolbar_title)
    AppCompatTextView mTitle = null;
    @BindView(R.id.rv_personal_setting)
    RecyclerView mRecylerView = null;

    @Override
    public Object setLayout() {
        return R.layout.delegate_person;
    }

    @Override
    public void onBindView(@Nullable Bundle savedInstanceState, View view) {
        mToolbar.setBackground(null);
        mTitle.setText(getString(R.string.bottom_user_value)+"\r\n"
        +getString(R.string.person_tip));
        initData();
    }

    private void initData() {
        final ListBean address = new ListBean.Builder()
                .setItemType(ListItemType.ARROW_ITEM_NOMAL)
                .setId(1)
                .setDelegate(new ResetPwdDelegate())
                .setText(getString(R.string.setting_reset_pwd))
                .create();
        final ListBean system = new ListBean.Builder()
                .setItemType(ListItemType.ARROW_ITEM_NOMAL)
                .setId(2)
                .setDelegate(new ResetPwdDelegate())
                .setText(getString(R.string.setting_version_update))
                .create();
        final List<ListBean> data = new ArrayList<>();
        data.add(address);
        data.add(system);
        final ListAdapter adapter = new ListAdapter(data);
        final LinearLayoutManager manager = new LinearLayoutManager(getContext());
        mRecylerView.setLayoutManager(manager);
        mRecylerView.setAdapter(adapter);
        mRecylerView.addOnItemTouchListener(new PersonalClickListener(this));
    }
}
